// Kony

#pragma once

#include "CoreMinimal.h"
#include "UI/Widget/BaseUserWidget.h"
#include "DraggingUserWidget.generated.h"

/**
 * 拖拽用户组件
 */
UCLASS()
class GASC_HUANLING_API UDraggingUserWidget : public UBaseUserWidget
{
	GENERATED_BODY()

public:


	// 是否处理点击事件（默认开启以阻止角色移动）
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UI Interaction")
	bool bHandleClickEvents = true;

	// 拖拽时的偏移量
	UPROPERTY(BlueprintReadOnly, Category = "UI Interaction")
	FVector2D DragOffset;
	// 是否正在拖拽
	UPROPERTY(BlueprintReadOnly, Category = "UI Interaction")
	bool bIsDragging = false;
	
	virtual void NativeConstruct() override;
	virtual FReply NativeOnMouseWheel(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override;
	virtual FReply NativeOnMouseMove(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override;
	virtual FReply NativeOnMouseButtonDown(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override;
	virtual FReply NativeOnMouseButtonUp(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override;
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
	class UCanvasPanel* DraggingCanvas;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
	class UOverlay* OverlayRoot;

protected:
	bool bDragging = false;
	float CurrentZoom = 1.0f;
	FVector2D LastMouseScreenPos;
};
